﻿namespace Example
{
    using System;

    using Cavity;
    using Cavity.IO;

    using TeaTime;

    using Xunit;

    [Comment("http://discretelogics.com/Product/TeaFiles")]
    public sealed class TeaFileFacts
    {
        [Fact]
        public void io()
        {
            using (var temp = new TempDirectory())
            {
                var file = temp.Info.ToFile("example.tea");
                using (var tea = TeaFile<Entry>.Create(file.FullName))
                {
                    tea.Write(new Entry { Time = DateTime.UtcNow, Value = 1.23m });
                    tea.Write(new Entry { Time = DateTime.UtcNow, Value = 9.99m });
                }

                using (var tea = TeaFile<Entry>.OpenRead(file.FullName))
                {
                    Assert.Equal(1.23m, tea.Read().Value);
                    Assert.Equal(9.99m, tea.Read().Value);
                }
            }
        }
    }
}